package com.tech.arno.spicy.mvp.presenterImpl;

import com.tech.arno.spicy.mvp.presenter.NewsPresenter;
import com.tech.arno.spicy.mvp.view.NewsView;
import com.tech.arno.spicy.network.http.RequestCenter;
import com.tech.arno.spicysdk.okhttp.listener.DisposeDataListener;

/*
*   @package:     com.tech.arno.spicy.mvp.presenterImpl
*   @fileName:    NewsPresenterImpl
*   @author:    ArnoFrost
*   @date:  2017/12/22 0022 9:06
*   @desc:     首页Fragment Presenter实现类
*/

public class NewsPresenterImpl implements NewsPresenter {
    NewsView newsView;

    public NewsPresenterImpl(NewsView newsView) {
        this.newsView = newsView;
    }

    /*
    * 发送首页列表数据请求
    * */
    @Override
    public void requestData() {
        RequestCenter.requestRecommandData(new DisposeDataListener() {
            @Override
            public void onSuccess(Object responseObj) {
                //真正逻辑
                newsView.loadSuccess(responseObj);
            }

            @Override
            public void onFailure(Object responseObj) {
                //提示用户网络有问题
                newsView.loadFail(responseObj);
            }
        });
    }

    @Override
    public void onDestroy() {
        newsView = null;
    }
}
